import { defineStore } from 'pinia'

// export const useCountStore = defineStore('count', {
//   state: () => ({
//     count: 0,
//     name: 'count'
//   }),
//   getters: {  //相当于vue的computed
//     double:(state) => state.count *2
//   },
//   actions:{ //相当于vue 的methods
//     // 这里可以做统一的逻辑收拢
//     increment(num: number){
//       this.count+=num
//     }
//   }
// })
import { ref } from 'vue'
export const useCountStore = defineStore('count', () => {
  const count = ref(0);
  const name = 'count';
  function double() {
    return count.value * 2
  }
  function increment(num: number) {
    count.value += num
  }

  return {
    count, name, double, increment
  }
})

